package com.ruoyi.web.StateDemo.service.impl;

import org.springframework.stereotype.Component;

@Component
public class ContextState  extends AbstractOrderState{



    /**
     * 订单状态
     */
    private  OrderState orderState;
    /**
     *   支付
     */
    @Override
    public  void paidEvent(ContextState contextState){
        orderState.paidEvent(contextState);

        System.out.println("当前的状态是"+getCurrentState().getValue());

    }

    /**
     * 取消订单
     */
    @Override
    public void cancelOrderEvent(ContextState contextState){
        orderState.cancelOrderEvent(contextState);
        System.out.println("当前的状态是"+getCurrentState().getValue());
    }
    /**
     * 核销订单
     */
    @Override
    public void verificationEvent(ContextState contextState){
        orderState.verificationEvent(contextState);
        System.out.println("当前的状态是"+getCurrentState().getValue());
    }
    /**
     * 申请退款
     */
    @Override
   public void applyRefundEvent(ContextState contextState){
        orderState.applyRefundEvent(contextState);
        System.out.println("当前的状态是"+getCurrentState().getValue());
    }
    /**
     * 退款成功
     */
    @Override
    public  void finshedRefundEvent(ContextState contextState){
        orderState.finshedRefundEvent(contextState);
        System.out.println("当前的状态是"+getCurrentState().getValue());
    }


    /**
     * 获取当前的状态值
     * @return
     */
    @Override
    public StateEnum getCurrentState() {
        return orderState.getCurrentState();
    }


    public void setOrderState(OrderState orderState) {
        this.orderState = orderState;
    }

    public OrderState getOrderState() {
        return orderState;
    }

}
